var avatarUp0, avatarUp1, avatarUp2, avatarUp3, avatarUp4, avatarUp5,
    avatarUp6, avatarUp7, avatarUp8, avatarUp9 = "";

function iconTypeChange() {
    avatarUp0 = new $IconUpload("avatar0");
    avatarUp0.initIcon();
    avatarUp1 = new $IconUpload("avatar1");
    avatarUp1.initIcon();
    avatarUp2 = new $IconUpload("avatar2");
    avatarUp2.initIcon();
    avatarUp3 = new $IconUpload("avatar3");
    avatarUp3.initIcon();
    avatarUp4 = new $IconUpload("avatar4");
    avatarUp4.initIcon();
    avatarUp5 = new $IconUpload("avatar5");
    avatarUp5.initIcon();
    avatarUp6 = new $IconUpload("avatar6");
    avatarUp6.initIcon();
    avatarUp7 = new $IconUpload("avatar7");
    avatarUp7.initIcon();
    avatarUp8 = new $IconUpload("avatar8");
    avatarUp8.initIcon();
    avatarUp9 = new $IconUpload("avatar9");
    avatarUp9.initIcon();
}

$(function () {
    iconTypeChange();
    $("#first_Content_nav > div").eq(0).click();
});

$("#first_Content_nav > div").click(function () {
    var index = $(this).index();
    $(this).addClass('selection').siblings().removeClass('selection');
    $("#first_Content_con > div").eq(index).show().siblings().hide();
    iconTypeChange();
});

function firstClose() {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
}

function storagePlant() {
    var reservationsId=window.parent.document.getElementById("reservationsId").value;
    var num=document.getElementById("num").value;
    var customerName=$("#customerName",parent.document).val();
    var doctor = $("#doctor").val();
    var nurse = $("#nurse").val();
    if(doctor==null || doctor=="" || doctor==undefined){
        alert("输入医生");
        return false;
    }
    if(nurse==null || nurse=="" || nurse==undefined){
        alert("输入护士");
        return false;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/storagePlant",
        type: "post",
        data: {
            "num": num,
            "reservationsId": reservationsId,
            "customerName": customerName,
            "doctor": doctor,
            "nurse": nurse
        },
        success: function (data) {
            Feng.success('操作成功!');
            window.parent.DentalPeripheryScoreTable.table.refresh();
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        }
    })
}

function subPlant() {
    if($("#avatar0PreId").children().length <= 0 || $("#avatar1PreId").children().length <= 0 || $("#avatar2PreId").children().length <= 0){
        Feng.error("请补全照片！");
        return false;
    }
    var reservationsId=window.parent.document.getElementById("reservationsId").value;
    var num=document.getElementById("num").value;
    var customerName=$("#customerName",parent.document).val();
    var doctor1 = $("#doctor1").val();
    var nurse1 = $("#nurse1").val();
    if(doctor1==null || doctor1=="" || doctor1==undefined){
        alert("输入医生");
        return false;
    }
    if(nurse1==null || nurse1=="" || nurse1==undefined){
        alert("输入护士");
        return false;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/subPlant",
        type: "post",
        data: {
            "reservationsId": reservationsId,
            "num": num,
            "customerName": customerName,
            "doctor1": doctor1,
            "nurse1": nurse1
        },
        success: function (data) {
            Feng.success('操作成功!');
            window.parent.DentalPeripheryScoreTable.table.refresh();
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        }
    })
}

$('#avatar0PreId,#avatar1PreId,#avatar2PreId,#avatar3PreId,#avatar4PreId,#avatar5PreId,#avatar6PreId,#avatar7PreId,#avatar8PreId,#avatar9PreId').on('click', '.cp_img_delete', function (e) {
    e.stopPropagation();
    var that = this;
    var id = $(that).parent().attr("id");
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/deletePlantImgs",
        type: "post",
        data: {"id": id},
        success: function (data) {
            $(that).parent().remove();
            Feng.success("删除成功！");
        },
        error: function (data) {
            alert("删除失败！");
        }
    });
});